<?php
session_start();
include_once('DAOUser.php');
$oUsuario = unserialize($_SESSION['oUsuario']); 
$jsDate = $_GET['fecha'];
$sSala = $_GET['sala'];
$iError = $_GET['error'];
$jsDateTS = strtotime($jsDate);
$sTodayDay = date('d');
$sTodayMonth = date('m');
$sTodayYear = date('Y'); 
$iAnio = date('Y', $jsDateTS );
$iMes = date('m', $jsDateTS );
$iDia = date('d', $jsDateTS );
if($oUsuario->getNivelUsuario() == "admin" || $oUsuario->getNivelUsuario() == "super_admin"){
if($iAnio >= $sTodayDay && $iMes >= $sTodayMonth && $iDia >= $sTodayDay){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Nuevo Evento</title>
<script src="../script/eventos.js" type="text/javascript"></script>
<meta name="viewport" content="width=device-width" />
<link href="../css/view.css" type="text/css" rel="stylesheet" media="screen" />
<link href="../css/view_mobile.css" type="text/css" rel="stylesheet" media="only scren and (min-width: 0px) and (max-width: 649px)"/> 
</head>

<body onBlur="self.focus()">
<div id="adminEvent">
    <div id="error"><?php if($iError == 1) echo "Faltaron Llenar Campos" ?></div>
    <form action="saveNewEvent.php" name="nuevoEvento" id="nuevoEvento" method="post">
    <fieldset>
    	<legend> Nuevo Evento </legend>
	<label for="evento">Nombre del Evento:</label><input type="text" name="evento" id="evento"/><br />
    <label for="equipo">Equipo:</label><textarea name="equipo" id="equipo"></textarea><br />
    <div class="inline"><label>Fecha de Inicio:</label><span id="fechaIni"><?php echo date('Y-m-d', $jsDateTS ); ?></span></div><br />
    <input type="hidden" value="<?php echo date('Y-m-d', $jsDateTS);?>" name="fechaInicio" />
    <div class="inline"><label for="fechaFin">Fecha de Culminaci&oacute;n</label>
    <select name="anioFin" id="anioFin">
    						<?php
								$sSelected = "";
								for($numOptionsAnio=2011;$numOptionsAnio<2026;$numOptionsAnio++){
									if($iAnio == $numOptionsAnio)
										$sSelected = 'selected="selected"';
									echo '<option value="'.$numOptionsAnio.'" '.$sSelected.' > '.$numOptionsAnio.' </option>';
									$sSelected = "";
								}	
							?>
    </select>
    <select name="mesFin" onchange="changeDays(document.getElementById('anioFin').value,this.value);">
    						<?php 
								for($numOptionsMes=1;$numOptionsMes<13;$numOptionsMes++){
									if($iMes == $numOptionsMes)
										$sSelected = 'selected="selected"';
									
									if($numOptionsMes<10)
											echo '<option value="0'.$numOptionsMes.'" '.$sSelected.'> 0'.$numOptionsMes.' </option>';
									else
										echo '<option value="'.$numOptionsMes.'" '.$sSelected.'> '.$numOptionsMes.' </option>';
									$sSelected = "";
								}
							?>
    </select>
    <span id="dias">
    <select name="diaFin">
    						<?php 
								for($numOptionsDia=1;$numOptionsDia<32;$numOptionsDia++){
									if($iDia == $numOptionsDia)
										$sSelected = 'selected="selected"';
									
									if($numOptionsDia<10)
										echo '<option value="0'.$numOptionsDia.'" '.$sSelected.'> 0'.$numOptionsDia.' </option>';
									else
										echo '<option value="'.$numOptionsDia.'" '.$sSelected.'> '.$numOptionsDia.' </option>';
									$sSelected = "";
								}
							?>
    </select></span></div><br />
    <div class="inline">
	<label>Horario:</label><select name="horaInicio">
    						<?php 
								for($numOptions=0;$numOptions<24;$numOptions++){
									if($numOptions<10)
										echo '<option value="0'.$numOptions.':00"> 0'.$numOptions.':00 </option><option value="0'.$numOptions.':30"> 0'.$numOptions.':30 </option>';
									else
										echo '<option value="'.$numOptions.':00"> '.$numOptions.':00 </option><option value="'.$numOptions.':30"> '.$numOptions.':30 </option>';
								}
							?>
                            </select> a
    						<select name="horaFin">
                            	<?php 
								for($numOptions=0;$numOptions<24;$numOptions++){
									if($numOptions<10)
										echo '<option value="0'.$numOptions.':00"> 0'.$numOptions.':00 </option><option value="0'.$numOptions.':30"> 0'.$numOptions.':30 </option>';
									else
										echo '<option value="'.$numOptions.':00"> '.$numOptions.':00 </option><option value="'.$numOptions.':30"> '.$numOptions.':30 </option>';
								}
							?>
                            </select></div><br />
    <label>Coordinador:</label><input type="text" name="solicitante" id="solicitante"/><br />
    <label>Correo:</label><input type="text" name="correo" id="correo"/><br />
    <label>Telefono:</label><input type="text" name="telefono" id="telefono"/>
    <input type="hidden" value="<?php echo $sSala; ?>" name="sala" />
    <input type="submit" name="guardar" value="Guardar" class="botonSubmit"  />
    </fieldset>
    </form>
</div>
<?php 
	}else
		echo "<h2>LA FECHA YA PASO</h2>";
}else
	echo "<h2>NO POSEE PERMISOS PARA AGREGAR EVENTOS</h2>"
?>
</body>
</html>